﻿using NovoSerDes.A2B.propeties_page.uipage;
using Sunny.UI;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace NovoSerDes.A2B.propeties_page
{
    public partial class Register_View : UIPage
    {
        public Register_View()
        {
            InitializeComponent();


            UIPage config_and_control_register_view = new config_and_control_register_view();
            config_and_control_register_view.Text = "Config and Control";
            this.uiTabControl2.AddPage(config_and_control_register_view);

            UIPage I2C_I2S_PDM_register_view = new I2C_I2S_PDM_register_view();
            I2C_I2S_PDM_register_view.Text = "I2C,I2S/PDM";
            this.uiTabControl2.AddPage(I2C_I2S_PDM_register_view);

            AdjustTabSizes();
        }
        private void AdjustTabSizes()
        {
            using (Graphics g = this.CreateGraphics())
            {
                int maxWidth = 0;
                for (int i = 0; i < uiTabControl2.TabCount; i++)
                {
                    // 获取选项卡文本的大小
                    SizeF textSize = g.MeasureString(uiTabControl2.TabPages[i].Text, uiTabControl2.Font);
                    maxWidth = Math.Max(maxWidth, (int)textSize.Width);
                }

                // 设置每个选项卡的大小
                uiTabControl2.ItemSize = new Size(maxWidth + 20, uiTabControl2.ItemSize.Height);
            }
        }
    }
}
